package Application.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import Application.entity.Essay;

public interface EssayDao {

	@Insert("insert into essay (title,content,collections,type,author,date,authorid)value(#{title},#{content},#{collections},#{type},#{author},#{date},#{authorid})")
	@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	public void insertEssay(Essay essay);
	
	@Select("select * from essay")
	public List<Essay> findEssayList();
	
	@Select("select * from essay where id=#{id}")
	public Essay findEssayById(int id);
	
	@Delete("delete from Essay where id=#{id}")
	public void deleteEssayById(int id);

	@Select("select * from essay where  title like % #{value} %")
	public List<Essay>  vague(String  value);
	
	@Select("select * from essay where authorid=#{authorid}")
	public List<Essay> findEssayByAuthor(int authorid);
}
